// pages/supply-install-service/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    list: [],
    param: {
      page: 1,
      pageSize: 10,
    },
    hasMore: true,
  },

  handlePaiDan(event) {
    const { id } = event.currentTarget.dataset;

    wx.navigateTo({
      url: "/pages/delivery-order/index?id=" + id,
    });
  },

  handleGetMore() {
    const { param } = this.data;

    param.page++;

    this.setData({ param });
  },

  getData() {
    const { param } = this.data;

    const params = { ...param };

    wx.ajax.post("queryWxazApplyPage.action", params, true).then((res) => {
      console.log(res);
      if (res.success) {
        const result = res.result;

        const oriList = this.data.list;

        this.setData({
          list: oriList.concat(result.pageList || []),
          hasMore: result.totalPages > result.page,
        });
      }
    });
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {},

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {},

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    const { param } = this.data;

    param.page = 1;

    this.setData({
      param,
      list: [],
    });

    this.getData();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {},

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {},

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {},

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
});
